package com.njupt.wuaiagent.rag;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.document.Document;
import org.springframework.ai.transformer.KeywordMetadataEnricher;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author: wujiaming
 * @CreateTime: 2025/5/19 19:43
 * @Description: DocumentTransFormer使用KeywordMetadataEnricher 基于AI自动解析文档文档中的关键词，添加到文档的元数据信息中
 * @Version: 1.0
 */


@Component
public class MyKeyWordEnricher {

    @Resource
    ChatModel dashscopeChatModel;
    public List<Document> enrichDocument(List<Document> documents){
        KeywordMetadataEnricher enricher = new KeywordMetadataEnricher(dashscopeChatModel, 5);
        return enricher.apply(documents);
    }
}
